// reliable_signal.c
#include <stdio.h>
#include <signal.h>
#include <unistd.h>

void sigHandler(int signum) {
    static int count = 0;
    count++;
    printf("Received signal: %d, count: %d\n", signum, count);
}

int main() {
    signal(SIGUSR1, sigHandler); // 不可靠信号
    struct sigaction act;
    sigemptyset(&act.sa_mask);
    act.sa_handler = sigHandler;
    sigaction(SIGRTMIN, &act, NULL); // 可靠信号
    while (1) {
        sleep(1);
    }
    return 0;
}
